local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
  packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
end


return require('packer').startup(function(use)
  use 'wbthomason/packer.nvim'
  use {
    'nvim-treesitter/nvim-treesitter',
    run = ':TSUpdate'
  }
  use {
    'nvim-lualine/lualine.nvim',
    requires = {'kyazdani42/nvim-web-devicons', opt = true}
  }
  use {'akinsho/bufferline.nvim', tag = "v2.*", requires = 'kyazdani42/nvim-web-devicons'}

  use {
    'kyazdani42/nvim-tree.lua',
    requires = {
      'kyazdani42/nvim-web-devicons', -- optional, for file icon
    },
    config = function() require'nvim-tree'.setup {} end
  }

  use {
    'neovim/nvim-lspconfig',
    requires = {
      {'saadparwaiz1/cmp_luasnip'},
      {'L3MON4D3/LuaSnip'},
      {'hrsh7th/nvim-cmp'},
      {'hrsh7th/cmp-path'},
      {'hrsh7th/cmp-nvim-lsp'},
      {'hrsh7th/cmp-buffer'},
      {'hrsh7th/cmp-cmdline'},
    }
  }

  -- use {
  --   'nmac427/guess-indent.nvim',
  --   config = function() require('guess-indent').setup {} end,
  -- }
  use {
    'Darazaki/indent-o-matic',
    config = function() 
      require('indent-o-matic').setup{
        max_lines = 2048,
        standard_widths = { 2, 4, 8 },
        skip_multiline = true,
      }
    end,
  }

  use {
      'stevearc/aerial.nvim',
      config = function() require('aerial').setup() end
  }

  use {
    'windwp/nvim-autopairs',
    config = function() require('nvim-autopairs').setup() end
  }

  use 'lukas-reineke/indent-blankline.nvim'

  use 'projekt0n/github-nvim-theme'
  use 'folke/tokyonight.nvim'

  use {
    'lewis6991/gitsigns.nvim',
    config = function() require('gitsigns').setup() end
  }

  use 'famiu/bufdelete.nvim'


  -- ts/js related plugins
  use 'JoosepAlviste/nvim-ts-context-commentstring'
  use 'numToStr/Comment.nvim'

  use 'glepnir/dashboard-nvim'

  use {
    "folke/which-key.nvim",
    config = function()
      require("which-key").setup {}
    end
  }
  
  use {
    'natecraddock/workspaces.nvim',
    config = function()
      require("workspaces").setup({
        hooks = {
          open = "NvimTreeOpen",
        }
      })
    end
  }

  use {
    'natecraddock/sessions.nvim',
    config = function() require("sessions").setup() end
  }

  -- Put this at the end after all plugins
  if packer_bootstrap then
    require('packer').sync()
  end
end)
